#include <bits/stdc++.h>
using namespace std;
#define ll long long

int jjpow(int, int);
int jjC(ll, ll);

const int N = 1e5 + 10, MOD = 1e9 + 7;

int n1, n2, q;
int leave1[N * 3], leave2[3 * N], q1[3*N], q2[3*N]; //leave记录是否有人，q1、q2是两个队列
int jjindex[N * 3], jjq[N * 3]; //jjindex记录某编号所在队列的位置，jjq记录某编号在哪个队列（1表示q1, 2表示q2)

/* 打印结果 */
void jjprint(){
    int i = 1;
    for(; i < n1; ++i) 
        if(leave1[i] == 0){
            printf("%d",q1[i]);
            ++i;
            break;
        }
    for(; i < n1; ++i){
        if(leave1[i] == 0){
            printf(" %d", q1[i]);
        }
    }
    i = 1;
    printf("\n");
    for(; i < n2; ++i) 
        if(leave2[i] == 0){
            printf("%d",q2[i]);
            ++i;
            break;
        }
    for(; i < n2; ++i){
        if(leave2[i] == 0){
            printf(" %d", q2[i]);
        }
    }
    printf("\n");
}

void solve(){
    /* printf("\n"); */
    int tmp;
    for(int i = 0; i < q; ++i){
        /* jjprint(); */
        scanf("%d", &tmp);
        int pos = jjindex[tmp];
        if(jjq[tmp] == 1){
            leave1[pos] = 1;
            jjq[tmp] = 2;
            jjindex[tmp] = n2;
            q2[n2++] = tmp;
        }else if(jjq[tmp] == 2){
            leave2[pos] = 1;
            jjq[tmp] = 1;
            jjindex[tmp] = n1;
            q1[n1++] = tmp;
        }
    }
    jjprint();
}

/* 初始化，q1的编号从1～n1, q2从n1+1~n2, jjq记录某编号所在队列，jjindex记录编号所在位置 */
void init(){
    scanf("%d%d%d", &n1, &n2, &q);    
    for(int i= 1; i <= n1; ++i){
        q1[i] = i;
        jjq[i] = 1;
        jjindex[i] = i;
    }
    for(int i= 1; i <= n2; ++i){
        q2[i] = n1 + i;
        jjq[n1 + i] = 2;
        jjindex[n1 + i] = i;
    }
    n1 ++;
    n2 ++;
}

int main(){
    #ifndef ONLINE_JUDGE
        auto start_clock = clock();
        //freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    #endif
    
    init();
    solve();
    
    #ifndef ONLINE_JUDGE
        auto end_clock = clock();
        //cout<<"runtime: "<<end_clock - start_clock<<"ms"<<endl;
    #endif
    return 0;
}

int jjpow(int a, int b){
    if(b == 2)return (a * a)%MOD;
    if(b == 1)return a;
    int ret1 = a, ret2 = a;
    int cnt1 = log(b)/log(2);
    int cnt2 = b - pow(2, cnt1);
    ret1 = jjpow(a, cnt2);
    for(int i = 0; i < cnt1; ++i){
        ret2 = (ret2 * ret2)%MOD;
    }
    return (ret1 * ret2)%MOD;
}

int jjC(ll a, ll b){
    int ret = 1, tmp = 1;
    for(int i = a; i > a - b; --i){
        ret = (ret * i)%MOD;
    }
    for(int i = 2; i <= b; ++i){
        tmp = (tmp * i)%MOD;
    }
    printf("%d %d\n", ret, tmp);
    return ret/tmp;
}
